<?php
declare (strict_types = 1);

namespace app\adminapi\controller\system;

use app\common\controller\BaseController;
use app\common\service\system\OperateLogService;
use think\Request;

class OperateLog extends BaseController
{
    public function __construct(OperateLogService $service)
    {
        $this->service = $service;
    }

    /**
     * 查询列表
     *
     * @param Request $request
     * @return \think\Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     */
    public function index(Request $request): \think\Response
    {
        $where = $request->param();
        return $this->success($this->service->getList($where));
    }

    /**
     * 查询一条记录
     *
     * @param $id
     * @return \think\Response
     */
    public function read($id): \think\Response
    {
        return $this->success($this->service->getInfo($id));
    }

    /**
     * 删除一条记录
     *
     * @param $id
     * @return \think\Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function delete($id): \think\Response
    {
        return $this->success($this->service->delete($id));
    }
}
